package com.example.wechat.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import com.example.wechat.fragment.FavoritesChatFragment;
import com.example.wechat.fragment.FavoritesArticleFragment;
import com.example.wechat.fragment.FavoritesLinkFragment;

public class FavoritesPagerAdapter extends FragmentStateAdapter {
    private static final int NUM_PAGES = 3;

    public FavoritesPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return new FavoritesChatFragment();
            case 1:
                return new FavoritesArticleFragment();
            case 2:
                return new FavoritesLinkFragment();
            default:
                throw new IllegalArgumentException("Invalid position: " + position);
        }
    }

    @Override
    public int getItemCount() {
        return NUM_PAGES;
    }
} 